package com.lmiot.floatviewsdklibrary.View;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.lkx.liandianqinew.R;
import com.lmiot.floatviewsdklibrary.SDK.YYFloatButton;

public class WrapFloatView extends FrameLayout {
    public static int viewHeight;
    public static int viewWidth;
    private Context mContext;
    private WindowManager.LayoutParams mParams;
    private WindowManager windowManager;

    public WrapFloatView(Context context) {
        this(context, null);
    }

    public WrapFloatView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public WrapFloatView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.mContext = context;
        this.windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        LayoutInflater.from(context).inflate(R.layout.library_layout_float, this);
        FloatView floatView = (FloatView) findViewById(R.id.floatView);
        viewWidth = floatView.getLayoutParams().width;
        viewHeight = floatView.getLayoutParams().height;
        floatView.setOnLocationChangeListener(new FloatView.OnLocationChangeListener() {
            /* class com.lmiot.floatviewsdklibrary.View.WrapFloatView.AnonymousClass1 */

            @Override // com.lmiot.floatviewsdklibrary.View.FloatView.OnLocationChangeListener
            public void result(float f, float f2, float f3, float f4) {
                WrapFloatView wrapFloatView = WrapFloatView.this;
                wrapFloatView.updateViewPosition(wrapFloatView.mContext, f, f2, f3, f4);
            }
        });
    }

    public void setParams(WindowManager.LayoutParams layoutParams) {
        this.mParams = layoutParams;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void updateViewPosition(Context context, float f, float f2, float f3, float f4) {
        this.mParams.x = (int) (f - f2);
        this.mParams.y = (int) (f3 - f4);
        YYFloatButton.setLastX(context, this.mParams.x);
        YYFloatButton.setLastY(context, this.mParams.y);
        this.windowManager.updateViewLayout(this, this.mParams);
    }
}
